package dao;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.ejb.Stateless;

import model.Train;

@Stateless
public class TrainDAO extends GenericDAO<Train> {
	
	public TrainDAO() {
		super(Train.class);
	}
	
	public Train findByNumber(Integer number) {
		Map<String, Object> parameters = new HashMap<String, Object>();
		parameters.put("trainNumber", number);
		List<Train> train = super.findManyResults(Train.FIND_BY_NUMBER, parameters);
		if (train != null) {
			if (train.isEmpty()) {
				return null;
			} else {
				return train.get(0);
			}
		} else {
			return null;
		}
	}
}
